{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "Both GOOGLE_API_KEY and GEMINI_API_KEY are set. Using GOOGLE_API_KEY.\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "## Royal Challengers Bengaluru Clinch Maiden IPL Title in Thrilling Final\n",
      "\n",
      "In a historic turn of events, Royal Challengers Bengaluru (RCB) have won their first-ever Indian Premier League (IPL) title, defeating Punjab Kings (PBKS) by a narrow margin of 6 runs in the final of the 2025 season. The nail-biting encounter took place on Tuesday, June 3, 2025, at the Narendra Modi Stadium in Ahmedabad.\n",
      "\n",
      "Opting to bat first, Royal Challengers Bengaluru posted a competitive total of 190 for the loss of 9 wickets in their allotted 20 overs. In response, Punjab Kings fought valiantly but ultimately fell short, finishing their innings at 184 for 7.\n",
      "\n",
      "The victory marks a significant moment for RCB, who have been a part of the tournament since its inception in 2008 and have reached the final on three previous occasions without success. This long-awaited triumph brought an end to their 18-year wait for the coveted trophy.\n",
      "economictimes.com, sportskeeda.com, jagranjosh.com, indiatimes.com, wikipedia.org\n"
     ]
    }
   ],
   "source": [
    "from google import genai\n",
    "from google.genai.types import Tool, GenerateContentConfig, GoogleSearch\n",
    "\n",
    "client = genai.Client()\n",
    "model_id = \"gemini-2.5-pro\"\n",
    "\n",
    "response = client.models.generate_content(\n",
    "    model=model_id,\n",
    "    contents='What was the latest Indian Premier League match and who won?',\n",
    "    config={\"tools\": [{\"google_search\": {}}]},\n",
    ")\n",
    "print(response.text)\n",
    "\n",
    "citations = ', '.join([site.web.title for site in response.candidates[0].grounding_metadata.grounding_chunks])\n",
    "print(citations)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": ".venv",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.12.9"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
